package com.yang.pojo;

import java.io.Serializable;

import com.yang.pojo.vo.ChangePojo;
import com.yang.pojo.vo.PrimaryKeyPojo;

/**
 * @author HP
 *
 */
public class Student implements PrimaryKeyPojo, ChangePojo, Comparable<Student>,Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//序列化忽略
	private transient boolean changeFlag = false;
	// 学生主键
	private Integer student_id;
	private String student_name;
	private Integer age;

	public Integer getStudent_id() {
		return student_id;
	}

	public void setStudent_id(Integer student_id) {
		this.student_id = student_id;
		updateChangeFlag();
	}

	public String getStudent_name() {
		return student_name;
	}

	public void setStudent_name(String student_name) {
		this.student_name = student_name;
		updateChangeFlag();
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
		updateChangeFlag();
	}

	// 获取该pojo的主键
	@Override
	public Integer getPrimaryKey() {

		return this.student_id;
	}

	// 设置该pojo 的主键
	@Override
	public void setPrimaryKey(Integer primaryKey) {
		this.student_id = primaryKey;
		updateChangeFlag();

	}

	private void updateChangeFlag() {
		if (!this.changeFlag) {
			this.changeFlag = true;
		}
	}

	/*
	 * 比较id大小 方便对pojo 进行排序
	 * 
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(Student o) {
		return this.getPrimaryKey() == null ? -1 : (o == null ? 1 : this.getPrimaryKey().compareTo(o.getPrimaryKey()));
	}

	@Override
	public Boolean isChange() {
		// TODO Auto-generated method stub
		return changeFlag;
	}

}
